import enterpriseCode from "./EnterpriseCode-Map/index.js";
import isTest from "./checkENV";


     /*setTimeout(() => {
          setCookie('sessionId',"fca38826a4324d2ebdbec4a0a72f5eec")
     }, 500);*/


    // let host = "http://njxs.weilian.cn";
    // let host = "http://test.njxs.weilian.cn";
    // let host = "http://uat.scn.njxs.wn.sunmath.cn";


    let port = window.location.port ? ":" + window.location.port : "";
    let host = "http://" + window.location.host + port;
    let testConfig = {
        "local_host": host,//域名
        "base_host": "http://test.vmbase.scn.weilian.cn",//172.19.6.152:33001
        "goods_host": "http://test.vmgoods.scn.weilian.cn",//172.19.6.152:33002
        "trade_host": "http://test.vmtrade.scn.weilian.cn",//172.19.6.152:33003
        "customer_host": "http://test.vmcustomer.scn.weilian.cn",//172.19.6.152:33004
        //      "customer_host": "172.19.6.152:33004",//172.19.6.152:33004
        "service_host": "http://test.vmservice.scn.weilian.cn",//172.19.6.152:33005,
        //运营后台查询首页配置相关数据（sessionId与商城首页查询的接口不同---通过getCookie("sessionId")获取）
        "config_host": "http://test.vmgoods.scn.weilian.cn",
        "config_commend": "/resourceConfig/resource/commend",
        "config_feature": "/resourceConfig/resource/feature",
        "config_ad": "/resourceConfig/resource/ad",
        "config_meal": "/resourceConfig/resource/meal",
        "config_category": "/resourceConfig/resource/category",
        //商城首页查询广告/餐点/分类等信息---通过localStorage.getItem("sessionId")获取
        "home_commend": "/resourceConfig/mobile/commend",
        "home_feature": "/resourceConfig/mobile/feature",
        "home_ad": "/resourceConfig/mobile/ad",
        "home_meal": "/resourceConfig/mobile/meal",
        "home_category": "/resourceConfig/mobile/category",
        //查询配置相关的一些参数
        "config_params": "/mallconfig/selectVO",

        "enterpriseid": 134,
        "enterpriseId": 134,
        "alertTime": 500,//弹出提示时间
        "alertTime_1": 500,//弹出提示时间
        "alertTime_2": 2000,//弹出提示时间
        "shopCode": "1613",
        "storeCode": "1613",
        "storeId": "1613",
        "enterpriseCode": enterpriseCode,
        "mall_file_host": "http://files.scn.weilian.cn",
        "FILE_HOST": "http://files.scn.weilian.cn",
        //以下是为了兼容之前的代码，后续应该会被替换，神奇，勿动
        "mall_base_host": "http://test.base.scn.weilian.cn",	//商城调用base模块的地址
        "mall_contract_host": "http://test.contract.scn.weilian.cn",	 //商城调用contract模块的地址
        "mall_finance_host": "http://test.finance.scn.weilian.cn",	 //商城调用finance模块的地址
        "mall_purchase_host": "http://test.purchase.scn.weilian.cn",	 //商城调用purchase模块的地址
        "mall_reportform_host": "http://test.reportform.scn.weilian.cn",	 //商城调用reportform模块的地址
        "mall_sale_host": "http://test.sale.scn.weilian.cn",	 //商城调用sale模块的地址
        "mall_supplier_host": "http://test.supplier.scn.weilian.cn",	  //商城调用supplier模块的地址
        "mall_wholesale_host": "http://test.wholesale.scn.weilian.cn",	//商城调用wholesale模块的地址
        "mall_storage_host": "http://test.storage.scn.weilian.cn",	//商城调用storage模块的地址,
        "mall_goods_host": "http://test.goods.scn.weilian.cn", //商城调用goods模块的地址
        "websocket_host": "172.16.36.71:43004",//测试scoket接口
        "traceSource": "http://test.sale.scn.weilian.cn:81/sale/H5/wnmobile/origins/index.html"//溯源码地址
    }
    let productionConfig = {
        "local_host": host,//域名
        "base_host": "http://vmbase.scn.weilian.cn",//172.19.6.152:33001
        "goods_host": "http://vmgoods.scn.weilian.cn",//172.19.6.152:33002
        "trade_host": "http://vmtrade.scn.weilian.cn",//172.19.6.152:33003
        "customer_host": "http://vmcustomer.scn.weilian.cn",//172.19.6.152:33004
        "service_host": "http://vmservice.scn.weilian.cn",//172.19.6.152:33005,
        //运营后台查询首页配置相关数据（sessionId与商城首页查询的接口不同---通过getCookie("sessionId")获取）
        "config_host": "http://vmgoods.scn.weilian.cn",
        "config_commend": "/resourceConfig/resource/commend",
        "config_feature": "/resourceConfig/resource/feature",
        "config_ad": "/resourceConfig/resource/ad",
        "config_meal": "/resourceConfig/resource/meal",
        "config_category": "/resourceConfig/resource/category",
        //商城首页查询广告/餐点/分类等信息---通过localStorage.getItem("sessionId")获取
        "home_commend": "/resourceConfig/mobile/commend",
        "home_feature": "/resourceConfig/mobile/feature",
        "home_ad": "/resourceConfig/mobile/ad",
        "home_meal": "/resourceConfig/mobile/meal",
        "home_category": "/resourceConfig/mobile/category",
        //查询配置相关的一些参数
        "config_params": "/mallconfig/selectVO",
        "enterpriseid": 134,
        "enterpriseId": 134,
        "alertTime": 500,//弹出提示时间
        "alertTime_1": 500,//弹出提示时间
        "alertTime_2": 2000,//弹出提示时间
        "storeCode": "1490",
        "storeId": "1490",
        "enterpriseCode": enterpriseCode,
        "mall_file_host": "http://files.scn.weilian.cn",
        "FILE_HOST": "http://files.scn.weilian.cn",
        "websocket_host": "172.16.51.8:43004",//scoket接口
        "traceSource": "http://test.sale.scn.weilian.cn:81/sale/H5/wnmobile/origins/index.html"//溯源码地址
    }
    let uatConfig = {
        "local_host": host,//域名
        "base_host": "http://uat.vmbase.wn.sunmath.cn",//172.19.6.152:33001
        "goods_host": "http://uat.vmgoods.wn.sunmath.cn",//172.19.6.152:33002
        "trade_host": "http://uat.vmtrade.wn.sunmath.cn",//172.19.6.152:33003
        "customer_host": "http://uat.vmcustomer.wn.sunmath.cn",//172.19.6.152:33004
        //      "customer_host": "172.19.6.152:33004",//172.19.6.152:33004
        "service_host": "http://uat.vmservice.wn.sunmath.cn",//172.19.6.152:33005,
        //运营后台查询首页配置相关数据（sessionId与商城首页查询的接口不同---通过getCookie("sessionId")获取）
        "config_host": "http://uat.vmgoods.wn.sunmath.cn",
        "config_commend": "/resourceConfig/resource/commend",
        "config_feature": "/resourceConfig/resource/feature",
        "config_ad": "/resourceConfig/resource/ad",
        "config_meal": "/resourceConfig/resource/meal",
        "config_category": "/resourceConfig/resource/category",
        //商城首页查询广告/餐点/分类等信息---通过localStorage.getItem("sessionId")获取
        "home_commend": "/resourceConfig/mobile/commend",
        "home_feature": "/resourceConfig/mobile/feature",
        "home_ad": "/resourceConfig/mobile/ad",
        "home_meal": "/resourceConfig/mobile/meal",
        "home_category": "/resourceConfig/mobile/category",
        //查询配置相关的一些参数
        "config_params": "/mallconfig/selectVO",
        "enterpriseid": 134,
        "enterpriseId": 134,
        "alertTime": 500,//弹出提示时间
        "alertTime_1": 500,//弹出提示时间
        "alertTime_2": 2000,//弹出提示时间
        "shopCode": "1490",
        "storeCode": "1490",
        "storeId": "1490",
        "enterpriseCode": enterpriseCode,
        "mall_file_host": "http://files.scn.weilian.cn",
        "FILE_HOST": "http://files.scn.weilian.cn",
        "websocket_host": "172.16.36.71:43004",//测试scoket接口
        "traceSource": "http://test.sale.scn.weilian.cn:81/sale/H5/wnmobile/origins/index.html"//溯源码地址
    }
    let preConfig = {
        "local_host": host,//域名
        "base_host": "http://pre.vmbase.scn.weilian.cn",//172.19.6.152:33001
        "goods_host": "http://pre.vmgoods.scn.weilian.cn",//172.19.6.152:33002
        "trade_host": "http://pre.vmtrade.scn.weilian.cn",//172.19.6.152:33003
        "customer_host": "http://pre.vmcustomer.scn.weilian.cn",//172.19.6.152:33004
        //      "customer_host": "172.19.6.152:33004",//172.19.6.152:33004
        "service_host": "http://pre.vmservice.scn.weilian.cn",//172.19.6.152:33005,
        //运营后台查询首页配置相关数据（sessionId与商城首页查询的接口不同---通过getCookie("sessionId")获取）
        "config_host": "http://pre.vmgoods.scn.weilian.cn",
        "config_commend": "/resourceConfig/resource/commend",
        "config_feature": "/resourceConfig/resource/feature",
        "config_ad": "/resourceConfig/resource/ad",
        "config_meal": "/resourceConfig/resource/meal",
        "config_category": "/resourceConfig/resource/category",
        //商城首页查询广告/餐点/分类等信息---通过localStorage.getItem("sessionId")获取
        "home_commend": "/resourceConfig/mobile/commend",
        "home_feature": "/resourceConfig/mobile/feature",
        "home_ad": "/resourceConfig/mobile/ad",
        "home_meal": "/resourceConfig/mobile/meal",
        "home_category": "/resourceConfig/mobile/category",
        //查询配置相关的一些参数
        "config_params": "/mallconfig/selectVO",
        "enterpriseid": 134,
        "enterpriseId": 134,
        "alertTime": 500,//弹出提示时间
        "alertTime_1": 500,//弹出提示时间
        "alertTime_2": 2000,//弹出提示时间
        "shopCode": "1490",
        "storeCode": "1490",
        "storeId": "1490",
        "enterpriseCode": enterpriseCode,
        "mall_file_host": "http://files.scn.weilian.cn",
        "FILE_HOST": "http://files.scn.weilian.cn",
        "traceSource": "http://test.sale.scn.weilian.cn:81/sale/H5/wnmobile/origins/index.html"//溯源码地址
    }
    if (isTest.isTest) {
        console.log("是测试环境");
        window.api = Object.assign({}, testConfig);
    } else if (isTest.isUat){
        console.log("演示环境");
        window.api = Object.assign({}, uatConfig);
    } else if (isTest.isPre){
        console.log("预发布环境");
        window.api = Object.assign({}, preConfig);
    } else {
        console.log("生产环境");
        window.api = Object.assign({}, productionConfig);
    }
    //设置门店id
    localStorage.setItem("storeCode", window.api.storeCode);
    localStorage.setItem("storeId", window.api.storeId);
